package com.sxt.bus.utils;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;

/**
 * 公共样式
 * 
 * @author LJH
 * 
 */
public class HSSFStyleUtils {
	/**
	 * 设置头部样式
	 * 
	 * @param workbook
	 * @return
	 */
	public static HSSFCellStyle getTitleStyle(HSSFWorkbook workbook) {
		HSSFCellStyle cellStyle = workbook.createCellStyle();
		// 设置内容水平居中
		cellStyle.setAlignment(HorizontalAlignment.CENTER);
		// 设置内容垂直居中
		cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
		// 设置字体
		HSSFFont font = workbook.createFont();
		font.setBold(true);// 设置加粗
		font.setFontName("华文行楷");// 设置字体
		font.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex());
		font.setFontHeightInPoints((short) 30);
		cellStyle.setFont(font);
		return cellStyle;
	}

	/**
	 * 设置小标题头部样式
	 * 
	 * @param workbook
	 * @return
	 */
	public static HSSFCellStyle getSecoundTitleStyle(HSSFWorkbook workbook) {
		HSSFCellStyle cellStyle = workbook.createCellStyle();
		// 设置内容水平居中
		cellStyle.setAlignment(HorizontalAlignment.CENTER);
		// 设置内容垂直居中
		cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
		// 设置字体
		HSSFFont font = workbook.createFont();
		font.setBold(true);// 设置加粗
		font.setFontHeightInPoints((short) 18);
		cellStyle.setFont(font);
		return cellStyle;
	}

	/**
	 * 设置表头部样式
	 * 
	 * @param workbook
	 * @return
	 */
	public static HSSFCellStyle getTableTitleStyle(HSSFWorkbook workbook) {
		HSSFCellStyle cellStyle = workbook.createCellStyle();
		// 设置内容水平居中
		cellStyle.setAlignment(HorizontalAlignment.CENTER);
		// 设置内容垂直居中
		cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
		// 设置字体
		HSSFFont font = workbook.createFont();
		font.setBold(true);// 设置加粗
		font.setFontHeightInPoints((short) 15);
		cellStyle.setFont(font);
		return cellStyle;
	}

	/**
	 * 设置表体部样式
	 * 
	 * @param workbook
	 * @return
	 */
	public static HSSFCellStyle getTableBodyStyle(HSSFWorkbook workbook) {
		HSSFCellStyle cellStyle = workbook.createCellStyle();
		// 设置内容水平居中
		cellStyle.setAlignment(HorizontalAlignment.CENTER);
		// 设置内容垂直居中
		cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
		// 设置字体
		HSSFFont font = workbook.createFont();
		font.setFontHeightInPoints((short) 12);
		cellStyle.setFont(font);
		return cellStyle;
	}
}
